package ve.com.wayoyo.wuml_case.DibujoDiagramas;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.Point;

public abstract class Componente {
	
		//Estados
		public final static int IDLE = 0;
		public final static int SELECTED = 1;
		public final static int CONNECTING = 2;
		public final static int LINKED = 3;
		public final static int INSIDE_PACKAGE = 4;
		public final static int INSIDE_DEFAULT_PACKAGE = 5;
	
		protected Point Anchor; //Varibale que determina el punto de inicio del componente.
		protected Point _centerPoint;
		protected String Titulo;
		protected int ID;
		protected int _currentState;
		protected String Tipo;
		protected ArrayList<CompConector> _conectorsBegining = new ArrayList<CompConector>();
		protected ArrayList<CompConector> _conectorsEnd = new ArrayList<CompConector>();
		protected BorderAnchors _topAnchors;
		protected BorderAnchors _leftAnchors;
		protected BorderAnchors _rightAnchors;
		protected BorderAnchors _bottomAnchors;
		protected float _width = 0;
		protected float _height = 80;
		
		public void set_currentState(int _currentState) {
			this._currentState = _currentState;
		}
		
		public float get_width() {
			return _width;
		}

		public float get_height() { 
			return _height;
		}

		public Point getAnchor() {
			return Anchor;
		}
		
		public void setAnchor(Point anchor) {
			Anchor = anchor;
		}
		
		public Point get_centerPoint() {
			return _centerPoint;
		}
		
		public String getTitulo() {
			return Titulo;
		}
		
		public void setTitulo(String titulo) {
			Titulo = titulo;
			actualizarAchorsPoints();
			actualizarPuntoCentral();
		}
		
		public int getID() {
			return ID;
		}
		
		public void setID(int iD) {
			ID = iD;
		}
		
		public String getTipo() {
			return Tipo;
		}
		
		public void setTipo(String tipo) {
			Tipo = tipo;
		}
		
		public ArrayList<CompConector> get_conectorsBegining() {
			return _conectorsBegining;
		}

		public ArrayList<CompConector> get_conectorsEnd() {
			return _conectorsEnd;
		}

		public void removeFocus(){
			_currentState = IDLE;
			for (CompConector value : _conectorsBegining) {
				value.setState(CompConector.IDLE_STATE);
			}
		}
		
		public void mover(int distX, int distY){
			Anchor.x += distX;
			Anchor.y += distY;
			actualizarAchorsPoints();
			actualizarPuntoCentral();
			for (CompConector value : _conectorsBegining) {
				value.actualizarRuta(this);
			}
			for (CompConector value : _conectorsEnd) {
				value.actualizarRuta(VistaDiagrama.getVista().getDiagrama().getComponenteById(value.get_fatherId()));
			}
		}
		
		public BorderAnchors get_leftAnchors() {
			return _leftAnchors;
		}

		public BorderAnchors get_rightAnchors() {
			return _rightAnchors;
		}

		public BorderAnchors get_bottomAnchors() {
			return _bottomAnchors;
		}
		
		public BorderAnchors get_topAnchors() {
			return _topAnchors;
		}
		
		public abstract void Dibujar(Canvas c,boolean isFcoused,float globalScale,int offSetX,int offSetY);
		public abstract boolean CalcularVisibilidad(int offSetX, int offSetY,float GlobalScale);
		public abstract boolean calcularTouch(Point touch);
		public abstract CompConector calcularTouchConectores(Point touch);
		public abstract void actualizarAchorsPoints();
		public abstract void actualizarPuntoCentral();
		public abstract String generarDOM();
		public abstract String getConectorsDOM();

		
		
}
